//
// Created by dxyinme on 2021/10/9.
//

#ifndef VSORT_SERIALIZER_H
#define VSORT_SERIALIZER_H

#include <cstddef>
#include <string>
#include <deque>

namespace Vsort {
namespace FileSort {

enum class SerializerType {
  DivideOperator,
  FixedLength,
  OtherFunction
};

class Serializer {
private:
  SerializerType serializer_type{SerializerType::FixedLength};

  std::deque<std::string> unread_buf;
  int ReadFromCharPtrInDivideOperator(char * s);

public:
  Serializer() = default;

  explicit Serializer(SerializerType s_type);

  // count how many items are there have not been read from serializer.
  size_t GetUnReadItemNum();

  // read some items from charPtr and return the last unused index of `s`
  // if read failed , return -1
  // confirm there is '\0' in the end of char ptr `s`
  int ReadFromCharPtr(char * s);

  const std::deque<std::string>& UnReadBufRef() const;

  ~Serializer();
};

}
}


#endif //VSORT_SERIALIZER_H
